package behaviour.strategy.strategy_demo1;

/**
 * 策略模式 实现接口的是加减乘除策略
 * 方法包含算法中不变的部分，策略包含变化的部分
 *
 * @author yeyangtao
 * @date 2019/12/5 15:08
 */
public class StrategyDemo {
    public static void main(String[] args) {
        Context context = new Context(new OperationAdd());
        System.out.println("加：" + context.executeStrategy(5, 3));
        context = new Context(new OpeartionSubstact());
        System.out.println("减:" + context.executeStrategy(5, 3));

        Context context1 = new Context(new OperationChu());
        System.out.println("除:" + context1.executeStrategy(4, 2));
    }
}
